package com.wisezone.workflow.web;

import java.util.List;

import com.wisezone.common.exception.WzWebException;
import com.wisezone.common.web.BaseFormController;
import com.wisezone.workflow.bean.form.WfActivityInstanceForm;
import com.wisezone.workflow.core.Activity;
import com.wisezone.workflow.core.ActivityInstance;
import com.wisezone.workflow.core.FlowEngine;
import com.wisezone.workflow.core.Link;
import com.wisezone.workflow.core.ProcessInstance;



/**
 * 工作流控制层基类 2010-08-23
 * @author shan
 *
 * @param <T>
 * @param <S>
 */
public  class WorkFlowController<T,S,F> extends BaseFormController<T, S, F> {
	
	private FlowEngine flowEngine;
	
	/**
	 * 获得流程连接列表
	 * @param activityInstId
	 * @return
	 * @throws RuntimeException
	 */
	public List<Link> getLinkList(Long activityInstId) throws WzWebException{
		
		ActivityInstance activityInst = this.flowEngine.loadActivityInstance(activityInstId);
		Activity activity = activityInst.getActivity();
		return activity.getLinks();
          
	}
	
	/**
	 * 获得活动实例表单列表
	 * @param processInstId
	 * @return
	 * @throws WzWebException
	 */
	public List<WfActivityInstanceForm> getActivityInstFormList(Long processInstId) throws WzWebException{
	     ProcessInstance processInst = this.flowEngine.loadProcessInstance(processInstId);
	     return processInst.getActivityInstFormList();
	} 

	public void setFlowEngine(FlowEngine flowEngine) {
		this.flowEngine = flowEngine;
	}
	
	
}
